<layout name="user" />
<!-- 搜索 -->
<div id="search" class="clearfix">
    <a class="prev fl" href="javascript:history.go(-1);" title="后退">&lt;</a>
    <div class="head fl">
        购物车
    </div>
</div>
<!-- 搜索 -->

<!-- 内容 -->
<div id="switch">
    <div class="empty-cart">
        <div class="cartlogo">空的购物车</div>
        <p class="message">没有宝贝哦，不如去添加宝贝</p>
        <ul class="carta">
            <li><a href="{:U('Face/Index/good')}">返回购物</a></li>
        </ul>
    </div>
</div>
<!-- 内容 -->

<!-- javascript -->
<script type="text/javascript">
    //购物车
    $(document).ready (function ()
    {
        var pl = $("i:last");
        var reg = /(.*[\:\：]\s*)([\+\d\.]+)(\s*元)/g;
        $ (".sy_minus").click (function ()
        {
            var me = $ (this), txt = me.next (":text"), pc = me.closest("p");
            var val = parseFloat (txt.val ());
            val = val < 1 ? 1 : val;
            txt.val (val - 1);
            var price = parseFloat (pc.prev("p").text().replace(reg,'$2')) * txt.val ();
            pc.next("p").text (pc.next("p").text().replace(reg, "$1" + price + "$3"));
            var sum = 0;
            $(".p_num").next("p").each(function (i, dom)
            {
                sum += parseFloat ($(this).text().replace(reg, "$2"));
            });
            pl.text(pl.text().replace(reg, "$1" + sum + "$3"));
        });

        $(".sy_plus").click (function ()
        {
            var me = $ (this), txt = me.prev (":text"), pc = me.closest("p");
            var val = parseFloat (txt.val ());
            txt.val (val + 1);
            var price = parseFloat (pc.prev("p").text().replace(reg,'$2')) * txt.val ();
            pc.next("p").text (pc.next("p").text().replace(reg, "$1" + price + "$3"));
            var sum = 0;
            $(".p_num").next("p").each(function (i, dom)
            {
                sum += parseFloat ($(this).text().replace(reg, "$2"));
            });
            pl.text(pl.text().replace(reg, "$1" + sum + "$3"));
        });
    })[0].onselectstart = new Function ("return false");
</script>
<!-- javascript -->